<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title></title>
    <link rel="stylesheet" href="../../plugins/layui/css/layui.css"/>
    <link rel="stylesheet" href="../../css/fa.css"/>
    <link rel="stylesheet" href="../../css/icon.css"/>
    <link rel="stylesheet" href="../../css/ares_animate.min.css"/>
    <link rel="stylesheet" href="../../css/ares_hover_variant.min.css"/>
    <link rel="stylesheet" href="../../css/ares_reboot.css"/>
    <link rel="stylesheet" href="../../css/app.min.css"/>
    <link rel="stylesheet" href="../../css/iframe.css"/>

    <link href="../../legacy/plugins/bootstrap3.3.4/bootstrap.min.css" rel="stylesheet">
    <link href="../../legacy/css/bootstrap-overwrite.css" rel="stylesheet">
    <link href="../../legacy/plugins/jqpagination/jqpagination.css" rel="stylesheet">
    <link href="../../legacy/plugins/jqGrid/ui.jqgrid.css" rel="stylesheet">
    <link href="../../legacy/plugins/iCheck/custom.css" rel="stylesheet">
    <link href="../../legacy/css/style.css" rel="stylesheet">
    <link href="../../legacy/css/mandy-style.css" rel="stylesheet">
    <link href="../../legacy/css/printer-gague.css" rel="stylesheet">
    <style>
        #patient-info-row label {
            font-weight: 400;
        }

    </style>

</head>
<body>
<div class="col-sm-12">
    <h2 id="gauge-name"></h2>
    <ol class="breadcrumb">
    </ol>
</div>
<div class="hide">
    <div id="gauge-title-patient-info" class="col-sm-12 m-b-lg">
        <div style="text-align: center;display: none;font-size: 24px" class="print print-title" id="print-title"></div>
        <div style="margin-bottom: 30px;text-align: right" class="hide" id="record-info">
            <label class="label-eval">评定人：</label>
            <label class="label-eval m-r-lg" id="record_medical" ></label>
            <label class="label-eval">评定日期：</label>
            <label  class="label-eval" id="record_date"></label>
        </div>
        <div style="margin-bottom: 30px;" id="patient-title">
            <label style="font-size: 16px;font-weight: 600;">基本信息</label>
        </div>
        <div class="row" id="patient-info-row">
            <label style="margin-left: 5%">患者编号：</label><label id="number">-</label>
            <label style="margin-left: 5%">姓名：</label><label id="name">-</label>
            <label style="margin-left: 5%">性别：</label><label id="sex">-</label>
            <label style="margin-left: 5%">年龄：</label><label id="age">-</label>
            <label style="margin-left: 5%">医保类别：</label><label id="insurance-type">-</label>
        </div>
    </div>
</div>

<div class="hide">
    <div id="print-btn" class="hide no-print col-sm-12" style="margin-top: 20px;text-align: center">
        <button class="btn btn-primary" onclick="$('#content_div').printArea();">打印</button>
    </div>
</div>

<div id="prcp_content" style="width: 100%;height: 100%"></div>
</body>
<script src="../../plugins/jquery-3.2.1.min.js"></script>
<script src="../../legacy/plugins/jquery.cookie.js"></script>
<script src="../../legacy/plugins/jqGrid/i18n/grid.locale-en.js"></script>
<script src="../../legacy/plugins/jqGrid/jquery.jqGrid.min.js"></script>
<script src="../../legacy/plugins/jqpagination/jquery.jqpagination.min.js"></script>
<script src="../../legacy/plugins/iCheck/icheck.min.js"></script>
<script src="../../legacy/plugins/autosize.js"></script>
<script src="../../legacy/plugins/jquery.PrintArea.js"></script>
<script src="../../legacy/js/fast-recovery.js"></script>
<script src="../../legacy/js/reuse.js"></script>
<script type="text/javascript" src="../../plugins/layui/layui.js"></script>
<script type="text/javascript" src="../../aresExtends/config/layuiConfig.js"></script>
<script>

    layui.use(['table', 'form', 'laydate', 'laypage', 'conf', 'utils', 'filters', 'dateFilters', 'greyServices', 'mandyServices', 'store', 'qs'], function (table, form, laydate, laypage, config, utils, filters, dateFilters, greyServices, mandyServices, store, qs) {
        var localHash = location.hash,
            queryStr = localHash.split('?')[1],
            routerParams = top.layui.routers.params,
            routerQuery = queryStr ? qs.parse(queryStr) : {};
        console.log(localHash, queryStr, routerParams, routerQuery)
        var gaugeRecordId = routerQuery.gaugeRecordId;
        var prcpItemId = routerQuery.prcpItemId;
        //通过这个类型来区分是否做重新评估
        var type = routerQuery.type;
        var editable = routerQuery.editable;

        var span_emr_number = $("#number");
        var span_patient_name = $("#name");
        var span_patient_sex = $("#sex");
        var span_patient_age = $("#age");
        var span_insurance_type = $("#insurance-type");

        var patientBirthday = null;

        var url;

        /**
         * tab页的项目id，用于区分选中的tab
         */
        var showId;

        mandyServices.mandy_get_prescription_item(prcpItemId).then(function (res) {
            var data = res.data;
            patientBirthday = data.prescription.medical_record.patient.birthday;

            span_emr_number.text(data.prescription.medical_record.number);

//         span_patient_name.text(getPrivatePatientName(data.prescription.medical_record.patient.name));
            span_patient_name.text(data.prescription.medical_record.patient.name);
            span_patient_sex.text(filters.sexFormat(data.prescription.medical_record.patient.sex));
            span_patient_age.text(filters.ageFormat(data.prescription.medical_record.patient.birthday));

            span_insurance_type.text(filters.insuranceTypeFormat(data.prescription.medical_record.insurance_type));

            url = data.gauge.url;

            utils.loadView("/pages/gauge/gauge_tab.html", $('#prcp_content'), function () {
                $("#gauge-name").text(data.gauge.name);
                $("#print-title").text(data.gauge.name);
                var pageStackTemp = [pageStack[0], pageStack[pageIdx - 2], pageStack[pageIdx - 1]];
                pageStack = pageStackTemp;
                pageIdx = 3;
//                createTitleNav(data.gauge.name);
                var d = $("#gauge-title-patient-info");
                $("#content_div div:first").before(d);
                var b = $("#print-btn");
                $("#content_div:last").append(b);


            });
        });

        function submitGaugeResult() {
            var res = getGaugeResult();

            //如果校验出错直接返回
            if (res == null) {
                return;
            }

            var result = JSON.stringify(res);

            if (type == 're_evaluation' || showId == -1) {
                //重新评估,新增项目且添加评估
                mandy_post_gauge_record_re_evaluation(prcpItemId, result, function (data) {
                    debugAlert(data);
                    utils.msgSuccess("提交成功");
                    setEditable(false);
                    setParamToUrl({"prcp_item_id": data.item_id});
                    loadTitle("/gauge/gauge_title.html");
                });
            } else {
                mandy_post_gauge_record_result(gaugeRecordId, result, function (data) {
                    debugAlert(data);
                    utils.msgSuccess("提交成功");
                    setEditable(false);
                    if (showId != null && showId != -1) {
                        setParamToUrl({"prcp_item_id": showId});
                    }
                    loadTitle("/gauge/gauge_title.html");
//                jsGoBack();
                });
            }


        }

        function myReset() {
            $("#content_div form")[0].reset();
            getCount();
        }

        function fastEval() {
            var fastEvalValue = $("#select_fast_eval").val();
            if (fastEvalValue == 1) {
                var minRadios = $(".min");
                $.each(minRadios, function (idx, minRadio) {
                    minRadio.checked = true;
                });
            } else if (fastEvalValue == 2) {
                var maxRadios = $(".max");
                $.each(maxRadios, function (idx, maxRadio) {
                    maxRadio.checked = true;
                });
            }

            changeSelect();
        }
    })
</script>


</html>